function distinct(array, keyGenerator) {
    if (!Array.isArray(array)) {
        throw new TypeError('Array should be an array');
    }
    let set = new Set()
    let key;
    let result = [];
    for (let i = 0; i < array.length; i++) {
        let item = array[i];
        key = keyGenerator(item)
        if (set.has(key)) {
            continue
        }
        set.add(key)
        result.push(item);
    }
    set = null;
    return result
}

const startArrayTools = {
    distinct
}
export default startArrayTools